package com.cdeledu.synchronized的ObjectClassThis;

/*-----------------
结果:
1
2//中间没有时间间隔
------------------*/
public class Material {

    private int data1=1;
    private Object lock1 =new Object();
    private Object lock2 =new Object();

    public void doSome() {
        synchronized (lock1) {
            try {
                System.out.println(++data1);
                Thread.sleep(2000);
            }catch(Exception e) {
                e.printStackTrace();
            }
        }
    }

    public void deOther() {
        synchronized (lock2) {
            System.out.println(data1);
        }

    }

}
